package com.smarth.zhizulian.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.smarth.zhizulian.R;
import com.smarth.zhizulian.adapter.MyPagerAdapter;
import com.smarth.zhizulian.app.BaseActivity;
import com.smarth.zhizulian.app.BaseConfig;
import com.smarth.zhizulian.app.EventFragment;
import com.smarth.zhizulian.entity.EventBean;
import com.smarth.zhizulian.fragment.FavoriteArticleFragment;
import com.smarth.zhizulian.fragment.FavoriteVideoFragment;
import com.smarth.zhizulian.fragment.GetMoneyFragment;
import com.smarth.zhizulian.fragment.MoneyDetailFragment;
import com.ogaclejapan.smarttablayout.SmartTabLayout;

import org.simple.eventbus.EventBus;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by 18865 on 2018/2/8.
 */

public class FavoriteActivity extends BaseActivity {
    @BindView(R.id.tl_tablayout)
    SmartTabLayout tlTablayout;
    @BindView(R.id.vp_viewpager)
    ViewPager vpViewpager;
    private MyPagerAdapter pagerAdapter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_favorite);
        ButterKnife.bind(this);
        setTitlebar("我的收藏", true, "编辑", new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EventBus.getDefault().post(new EventBean("FavoriteActivity"), BaseConfig.EventTag.EDIT_FAVORITE);
            }
        });
        initTab();

    }

    private void initTab() {
        List<Fragment> fragmentList = new ArrayList<>();
        fragmentList.add(new FavoriteArticleFragment());
        fragmentList.add(new FavoriteVideoFragment());
        List<String> titleList = new ArrayList<>();
        titleList.add("文章");
        titleList.add("视频");
        pagerAdapter = new MyPagerAdapter(mContext, getSupportFragmentManager(), fragmentList, titleList);
        vpViewpager.setAdapter(pagerAdapter);
        tlTablayout.setViewPager(vpViewpager);

    }

    public static void open(Context context) {
        Intent i = new Intent(context, FavoriteActivity.class);
        context.startActivity(i);
    }

}
